'use strict';

var mongoose = require('mongoose'),
    Schema = mongoose.Schema;

var MeetingSchema = new Schema({
  name: String,
  size: Number,
  actual_size: {type: Number, default: 0},
  date: Date,
  status: {type: String, default: "wait"},
  meta: {
    created_at: {type: Date, default: Date.now},
    updated_at: {type: Date, default: Date.now}
  }
});

MeetingSchema.pre('save', function(next) {
  if (this.isNew)
    this.meta.created_at = this.meta.updated_at = Date.now;
  else
    this.meta.updated_at = Date.now;
  next();
})

module.exports = mongoose.model('Meeting', MeetingSchema);
